;
(function () {

  'use strict';

  angular.module('services.customActivity.summary')
    .service('summaryMaxProcessTimeService', summaryMaxProcessTimeService)
    .service('summaryAvgProcessTimeService', summaryAvgProcessTimeService)
    .service('summaryMinProcessTimeService', summaryMinProcessTimeService)
    .service('summaryMaxThroughputService', summaryMaxThroughputService)
    .service('summaryMaxTpsService', summaryMaxTpsService)
    .service('summaryAvgTpsService', summaryAvgTpsService);

  function summaryMaxProcessTimeService(Restangular, generatorSummaryPageService) {

    this.upay = 0;
    this.tmall = 0;
    this.scpay = 0;
    this.bank = 0;
    this.vces = 0;
    this.lingxi = 0;
    var that = this;

    this.init = function () {

      if (generatorSummaryPageService.pageInfo.preview) {
        setTimeout(function () {
          that.loading = true;
          that.upay = 0;
          that.tmall = 0;
          that.scpay = 0;
          that.bank = 0;
          that.vces = 0;
          that.lingxi = 0;
        }, 0);
        return;
      }

      that.loading = false;
      Restangular.all('sas/customActivity/summary/maxProcessTime/query').post({
        summaryId: generatorSummaryPageService.pageInfo.summaryId
      }).then(function (result) {
        that.loading = true;
        if (result.state === '10000') {
          that.upay = result.data.upay;
          that.tmall = result.data.tmall;
          that.scpay = result.data.scpay;
          that.bank = result.data.bank;
          that.vces = result.data.vces;
          that.lingxi = result.data.lingxi;
        } else {
          that.upay = 0;
          that.tmall = 0;
          that.scpay = 0;
          that.bank = 0;
          that.vces = 0;
          that.lingxi = 0;
        }
      });
    };
  }

  summaryMaxProcessTimeService.$inject = ['Restangular', 'generatorSummaryPageService'];

  function summaryAvgProcessTimeService(Restangular, generatorSummaryPageService) {

    this.upay = 0;
    this.tmall = 0;
    this.scpay = 0;
    this.bank = 0;
    this.vces = 0;
    this.lingxi = 0;
    var that = this;

    this.init = function () {

      if (generatorSummaryPageService.pageInfo.preview) {
        setTimeout(function () {
          that.loading = true;
          that.upay = 0;
          that.tmall = 0;
          that.scpay = 0;
          that.bank = 0;
          that.vces = 0;
          that.lingxi = 0;
        }, 0);
        return;
      }

      that.loading = false;
      Restangular.all('sas/customActivity/summary/averageProcessTime/query').post({
        summaryId: generatorSummaryPageService.pageInfo.summaryId
      }).then(function (result) {
        that.loading = true;
        if (result.state === '10000') {
          that.upay = result.data.upay;
          that.tmall = result.data.tmall;
          that.scpay = result.data.scpay;
          that.bank = result.data.bank;
          that.vces = result.data.vces;
          that.lingxi = result.data.lingxi;
        } else {
          that.upay = 0;
          that.tmall = 0;
          that.scpay = 0;
          that.bank = 0;
          that.vces = 0;
          that.lingxi = 0;
        }
      });
    };
  }

  summaryAvgProcessTimeService.$inject = ['Restangular', 'generatorSummaryPageService'];

  function summaryMinProcessTimeService(Restangular, generatorSummaryPageService) {

    this.upay = 0;
    this.tmall = 0;
    this.scpay = 0;
    this.bank = 0;
    this.vces = 0;
    this.lingxi = 0;
    var that = this;

    this.init = function () {

      if (generatorSummaryPageService.pageInfo.preview) {
        setTimeout(function () {
          that.loading = true;
          that.upay = 0;
          that.tmall = 0;
          that.scpay = 0;
          that.bank = 0;
          that.vces = 0;
          that.lingxi = 0;
        }, 0);
        return;
      }

      that.loading = false;
      Restangular.all('sas/customActivity/summary/minProcessTime/query').post({
        summaryId: generatorSummaryPageService.pageInfo.summaryId
      }).then(function (result) {
        that.loading = true;
        if (result.state === '10000') {
          that.upay = result.data.upay;
          that.tmall = result.data.tmall;
          that.scpay = result.data.scpay;
          that.bank = result.data.bank;
          that.vces = result.data.vces;
          that.lingxi = result.data.lingxi;
        } else {
          that.upay = 0;
          that.tmall = 0;
          that.scpay = 0;
          that.bank = 0;
          that.vces = 0;
          that.lingxi = 0;
        }
      });
    };
  }

  summaryMinProcessTimeService.$inject = ['Restangular', 'generatorSummaryPageService'];

  function summaryMaxThroughputService(Restangular, generatorSummaryPageService) {

    this.upay = 0;
    this.tmall = 0;
    this.scpay = 0;
    this.bank = 0;
    this.vces = 0;
    this.lingxi = 0;
    var that = this;

    this.init = function () {

      if (generatorSummaryPageService.pageInfo.preview) {
        setTimeout(function () {
          that.loading = true;
          that.upay = 0;
          that.tmall = 0;
          that.scpay = 0;
          that.bank = 0;
          that.vces = 0;
          that.lingxi = 0;
        }, 0);
        return;
      }

      that.loading = false;
      Restangular.all('sas/customActivity/summary/maxThroughput/query').post({
        summaryId: generatorSummaryPageService.pageInfo.summaryId
      }).then(function (result) {
        that.loading = true;
        if (result.state === '10000') {
          that.upay = result.data.upay;
          that.tmall = result.data.tmall;
          that.scpay = result.data.scpay;
          that.bank = result.data.bank;
          that.vces = result.data.vces;
          that.lingxi = result.data.lingxi;
        } else {
          that.upay = 0;
          that.tmall = 0;
          that.scpay = 0;
          that.bank = 0;
          that.vces = 0;
          that.lingxi = 0;
        }
      });
    };
  }

  summaryMaxThroughputService.$inject = ['Restangular', 'generatorSummaryPageService'];

  function summaryMaxTpsService(Restangular, generatorSummaryPageService) {

    this.upay = 0;
    this.tmall = 0;
    this.scpay = 0;
    this.bank = 0;
    var that = this;

    this.init = function () {

      if (generatorSummaryPageService.pageInfo.preview) {
        setTimeout(function () {
          that.loading = true;
          that.upay = 0;
          that.tmall = 0;
          that.scpay = 0;
          that.bank = 0;
          that.vces = 0;
          that.lingxi = 0;
        }, 0);
        return;
      }

      that.loading = false;
      Restangular.all('sas/customActivity/summary/maxThroughput/query').post({
        summaryId: generatorSummaryPageService.pageInfo.summaryId
      }).then(function (result) {
        that.loading = true;
        if (result.state === '10000') {
          that.upay = result.data.upay;
          that.tmall = result.data.tmall;
          that.scpay = result.data.scpay;
          that.bank = result.data.bank;
          that.vces = result.data.vces;
          that.lingxi = result.data.lingxi;
        } else {
          that.upay = 0;
          that.tmall = 0;
          that.scpay = 0;
          that.bank = 0;
          that.vces = 0;
          that.lingxi = 0;
        }
      });
    };
  }

  summaryMaxTpsService.$inject = ['Restangular', 'generatorSummaryPageService'];

  function summaryAvgTpsService(Restangular, generatorSummaryPageService) {

    this.upay = 0;
    this.tmall = 0;
    this.scpay = 0;
    this.bank = 0;
    var that = this;

    this.init = function () {

      if (generatorSummaryPageService.pageInfo.preview) {
        setTimeout(function () {
          that.loading = true;
          that.upay = 0;
          that.tmall = 0;
          that.scpay = 0;
          that.bank = 0;
          that.vces = 0;
          that.lingxi = 0;
        }, 0);
        return;
      }

      that.loading = false;
      Restangular.all('sas/customActivity/summary/avgThroughput/query').post({
        summaryId: generatorSummaryPageService.pageInfo.summaryId
      }).then(function (result) {
        that.loading = true;
        if (result.state === '10000') {
          that.upay = result.data.upay;
          that.tmall = result.data.tmall;
          that.scpay = result.data.scpay;
          that.bank = result.data.bank;
          that.vces = result.data.vces;
          that.lingxi = result.data.lingxi;
        } else {
          that.upay = 0;
          that.tmall = 0;
          that.scpay = 0;
          that.bank = 0;
          that.vces = 0;
          that.lingxi = 0;
        }
      });
    };
  }

  summaryAvgTpsService.$inject = ['Restangular', 'generatorSummaryPageService'];
})();